package com.taotao.service.impl;

import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.taotao.common.pojo.BaseResult;
import com.taotao.mapper.EyLanguageMapper;
import com.taotao.pojo.EyLanguage;
import com.taotao.pojo.EyLanguageExample;
import com.taotao.service.LanguageService;
import com.taotao.service.ParamService;

@Service
public class LanguageServiceImpl implements LanguageService {
	
	BaseResult baseResult = new BaseResult();
	@Autowired
	EyLanguageMapper eyLanguageMapper;
	@Autowired
	ParamService paramService;
	
	@Override
	public Map<String, Object> getLanguage(Map<String, String> map) {
		try {
			InputStream in;
			String language = paramService.getParam("language");
	        
	        EyLanguageExample example = new EyLanguageExample();
			List<EyLanguage> list = eyLanguageMapper.selectByExample(example);
			HashMap<String,String> returnMap=new HashMap<String,String>();
			for (EyLanguage l:list){
				if(language.equalsIgnoreCase("en")){
					returnMap.put(l.getLanguageKey(),l.getLanguageEn());
				}else{
					returnMap.put(l.getLanguageKey(),l.getLanguageCn());
				}
			}
			
			return baseResult.getSuccMap(returnMap);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}


}
